trigger NewQniqueAuthors on MZ_Playlist_Entry__c (after insert, after delete) {
    List<MZ_Playlist_Entry__c> tracks = new List<MZ_Playlist_Entry__c>([Select id, Name, MZ_Playlist_ref__c , MZ_Track_ref__r.MZ_Author_ref__c From MZ_Playlist_Entry__c  ]);
    Map<id,  Set<String>> trackMap = new Map<id, Set<String>>();
    for(MZ_Playlist_Entry__c track: tracks){
       if(!trackMap.containsKey(track.MZ_Playlist_ref__c)){
           trackMap.put(track.MZ_Playlist_ref__c , new Set<String>());
       }
       trackMap.get(track.MZ_Playlist_ref__c).add(track.MZ_Track_ref__r.MZ_Author_ref__c);

    }
    List<MZ_Playlist__c> authorNumber =[Select id, Name, MZ_Unique_Authors_Number__c From MZ_Playlist__c];
    for(MZ_Playlist__c playlist: authorNumber ){
        playlist.MZ_Unique_Authors_Number__c = trackMap.get(playlist.id).size();
     }
  update authorNumber; 
}

   // Map<id,  Set<Integer>> trackMap = new Map<id, Set<Integer>>();
   /// for(MZ_Playlist_Entry__c track: tracks){
     //   if(!trackMap.containsKey(track.MZ_Playlist_ref__c)){
     //       trackMap.put(track.MZ_Playlist_ref__c , new Set<Integer>());
     //      // trackMap.get(track.MZ_Playlist_ref__c).add(0);
    //       // trackMap.put(track.MZ_Playlist_ref__c , 0);
     //   }
    //   
    //   // trackMap.put(track.MZ_Playlist_ref__c , trackMap.get(track.MZ_Playlist_ref__c)+1);
    //       trackMap.get(track.MZ_Playlist_ref__c).add(trackMap.get(track.MZ_Playlist_ref__c));
    //    // System.debug(track.MZ_Playlist_ref__c+'::::::'+trackMap.get(track.MZ_Playlist_ref__c));
    
    
    
            // playlist.MZ_Unique_Authors_Number__c = trackMap.get(playlist.id);